Skip to content

Parse the format of a string to convert it into a timestamp, and calculate the interval between two time values

Use the date_parse(UsageEndTime, '%Y-%m-%d %H:%i:%S') function to format the value of the UsageEndTime field. Use the date_diff('hour', UsageStartTime, UsageEndTime) function to calculate the interval in hours between two time values. The results are displayed in a table.

SQL
|
select
  date_parse(UsageEndTime, '%Y-%m-%d %H:%i:%S') as "Format value of the UsageEndTime field",
  date_diff('hour', UsageStartTime, UsageEndTime) as "Calculate the time difference in hours between the values of the UsageStartTime and UsageEndTime fields"